package com.service.business.banklock.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.service.business.banklock.controller.req.PageBankLockTypeReq;
import com.service.business.banklock.service.MemberBankLockTypeService;
import com.service.core.rest.response.CommonPageRep;
import com.service.dao.enums.BankLockStatusEnum;
import com.service.dao.mapper.MemberBankLockTypeMapper;
import com.service.dao.model.MemberBankLockType;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberBankLockTypeServiceImpl extends ServiceImpl<MemberBankLockTypeMapper, MemberBankLockType> implements MemberBankLockTypeService {

	/**
	 * 锁仓周期列表
	 *
	 * @param req
	 * @return
	 */
	@Override
	public CommonPageRep<MemberBankLockType> list(PageBankLockTypeReq req) {
		Page<MemberBankLockType> page = PageHelper.startPage(req.getPageNo(), req.getPageSize());
		List<MemberBankLockType> list = baseMapper.selectList(new LambdaQueryWrapper<MemberBankLockType>()
				.eq(MemberBankLockType::getTypeStatus, BankLockStatusEnum.lock_type_enable_status)
				.orderByAsc(MemberBankLockType::getLockCycle));
		return CommonPageRep.buildResultRep(page, list);
	}
}
